package com.lc202309;

/**
 * Description:
 *
 * @Create 2023/9/27 23:49
 * @Version 1.0
 */
public class Solution70 {
    public int climbStairs1(int n) {
        if (n == 1) {
            return 1;
        }
        if (n == 2) {
            return 2;
        }
        return climbStairs1(n - 1) + climbStairs1(n - 2);
    }

    public int climbStairs(int n) {
        if (n == 1) {
            return 1;
        }
        if (n == 2) {
            return 2;
        }
        int first = 1;
        int end = 2;
        int tmp;
        for (int i = 2; i < n; i++) {
            tmp = first;
            first = end;
            end = tmp + end;
        }
        return end;
    }
}
